package com.ysd.modules.sys.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.utils.PageUtils;
import com.ysd.modules.sys.dao.SysSchoolDao;
import com.ysd.modules.sys.entity.SysSchoolEntity;
import com.ysd.modules.sys.service.SysSchoolService;

@Service
public class SysSchoolServiceImpl extends ServiceImpl<SysSchoolDao, SysSchoolEntity> implements SysSchoolService {

	@Override
	public int addSchool(SysSchoolEntity s) {
		
		return baseMapper.insert(s);
	}

	@Override
	public int delSchool(Integer id) {
		
		return baseMapper.deleteById(id);
	}

	@Override
	public int updateSchool(SysSchoolEntity s) {
		return baseMapper.updateById(s);
	}

	@Override
	public PageUtils getSchool(String name, String address, Integer page, Integer limit) {
		Page<SysSchoolEntity> pageInfo = new Page<SysSchoolEntity>(page,limit);
    	QueryWrapper<SysSchoolEntity> wapper = new QueryWrapper<SysSchoolEntity>();
    	if(name !=null && name != "") {
    		wapper.like("name", name);
    	}
    	if(address != null && address != "") {
    		wapper.like("address", address);
    	}
		return new PageUtils(this.page(pageInfo, wapper));
	}

}
